<?php
    require_once('init.php');    
    require_once('header.php');
    if(isset($_SESSION['commande']) && $_SESSION['commande'] instanceof Commande) {
        $details = $_SESSION['commande']->getCommandeDetails();
        if(!empty($details)) {
            echo    '<table class="table_panier">
                        <thead>
                            <tr>
                                <th>Code Article</th>
                                <th>Nom</th>
                                <th>Quantité</th>
                                <th>Prix</th>
                            </tr>
                        </thead>
                        <tbody>';
            foreach($details as $pd) {
                echo        '<tr>
                                <td>
                                    '.$pd->getProduit()->getReference().'
                                </td>
                                <td>
                                    '.$pd->getProduit()->getLibelle().'
                                </td>
                                <td>
                                    '.$pd->getQuantite().'
                                </td>
                                <td>
                                    '.$pd->getProduitPrixUnit().' €
                                </td>
                            </tr>';
            }
            echo        '</tbody>
                        <tfoot>
                            <tr>
                                <td>
                                    Total HT
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    '.$_SESSION['commande']->getPrixTotalHt().' €
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    TVA
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    '.($_SESSION['commande']->getPrixTotalTtc() - $_SESSION['commande']->getPrixTotalHt()).' €
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Total TTC
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    '.$_SESSION['commande']->getPrixTotalTtc().'
                                </td>
                            </tr>
                        </tfoot>
                    </table>';
        }
        echo    '<div class="resume_commande">
                    Transporteur : '.$_SESSION['commande']->getTransporteur().'<br>
                    Moyen de paiement : '.$_SESSION['commande']->getMoyenPaiement().'<br>
                </div>
                <form method="post" action="https://www.sandbox.paypal.com/cgi-bin/webscr"">
                    <input alt="Paiement Paypal" name="submit" src="img/btn_paypal.gif" type="image"/>
                    <input type="hidden" name="amount" value="'.$_SESSION['commande']->getPrixTotalHt().'" />
                    <input type="hidden" name="currency_code" value="EUR" />
                    <input type="hidden" name="cmd" value="_xclick" />
                    <input name="shipping" type="hidden" value="0.00" />
                    <input name="tax" type="hidden" value="'.($_SESSION['commande']->getPrixTotalTtc()-$_SESSION['commande']->getPrixTotalHt()).'" />
                    <input type="hidden" name="item_name" value="GrindHouse Leather" />
                    <input type="hidden" name="lc" value="FR" />
                    <input name="no_note" type="hidden" value="1" />
                    <input type="hidden" name="bn" value="GHL_BuyNow_WPS_FR" />
                    <input type="hidden" name="custom" value="'.$_SESSION['client']->getId().'" />
                    <input type="hidden" name="business" value="groupe4_equipe6@gmail.com" />
                    <input type="hidden" name="return" value="'.__ADDRESS_WEBSITE__.'validation_paiement.php" />
                    <input type="hidden" name="cancel_return" value="'.__ADDRESS_WEBSITE__.'paiement.php?erreur=1" />
                    <input type="hidden" name="notify_url" value="'.__ADDRESS_WEBSITE__.'validation_paiement.php" />
                </form>';
    }
    else {
        echo    'Votre panier est actuellement vide';
    }
    
?>
